package ar.org.cfired.creditos;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.jbpm.api.Configuration;
import org.jbpm.api.Execution;
import org.jbpm.api.ExecutionService;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.TaskService;
import org.jbpm.api.task.Task;

import ar.org.cfired.hibernate.utils.HibernateUtil;

public class PruebaProceso {

	public static void main(String args[]) {
		Integer cre_id = 139;
    	//Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		//Transaction t = session.beginTransaction();
		
		 ProcessEngine processEngine = new Configuration().buildProcessEngine();
		 TaskService taskService = processEngine.getTaskService();
		 ExecutionService executionService = processEngine.getExecutionService();
		 
		Task tarea = taskService.getTask("14628");
		System.out.println(tarea.getActivityName());
		System.out.println(tarea.getAssignee()); 
		Execution ex = executionService.findExecutionById(tarea.getExecutionId());
		System.out.println(ex.getId());
		
		System.out.println(ex.getProcessDefinitionId().substring(0,ex.getProcessDefinitionId().indexOf("-")));
		System.out.println(ex.getProcessInstance());
		//System.exit(0);
		//executionService.setVariable(ex.getId(), "solDelega", "true"); 
		//executionService.setVariable(ex.getId(), "solDelega", "false");
		//executionService.setVariable(ex.getId(), "solUEP", "tecnicosBA");
		
		taskService.completeTask("14628", "Aceptar");
	}
}
